<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of GlobalSettingController
 *
 * @author minh.mai
 */
class GlobalsettingController extends AdminController
{      
    public function actionIndex()
    {                
        $model = Settings::model()->findAll();
        if (isset($_POST['Settings'])) {
            $model[0]->attributes = $_POST['Settings'];
            $current_date = date(LGConstant::DATE_FORMAT_FOR_DATABASE);
            $logedInUser = User::model()->findByPk(Yii::app()->user->id);
            $model[0]->update_date = $current_date;
            $model[0]->updated_by = $logedInUser->username;
            if ($model[0]->validate()) {
                $model[0]->update();
                $this->showMessage(MsgType::SUCCESS, t('MSG_SUCCESS','messages',array('{0}'=>'Settings','{1}'=>'updated')));
                $this->redirect(url(app()->controller->id));
            }
        }        
        return $this->render('index', array('model'=>$model[0]));
    }
}
?>